//
//  MADataPickView.m
//  meiang_edu
//
//  Created by hfcb on 2018/9/12.
//  Copyright © 2018年 com.meiang.meiang_edu. All rights reserved.
//

#import "MADataPickView.h"

#import <zhPopupController.h>

@interface MADataPickView ()
@property (weak, nonatomic) IBOutlet UIDatePicker *datePick;

@end


@implementation MADataPickView

- (void)awakeFromNib {
    [super awakeFromNib];
    self.autoresizingMask = UIViewAutoresizingNone;
    self.layer.cornerRadius = 10;
    self.layer.masksToBounds = YES;
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        self = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject];
    }
    return self;
}

+ (instancetype)datePickView:(OKBlock)successBlock cancelBlock:(OKBlock)cancelBlock {
    MADataPickView *view = [[MADataPickView alloc] init];
    view.width = SCREEN_WIDTH * 0.7;
    view.height = 218;
    if (successBlock) {
        view.successBlock = successBlock;
    }
    if (cancelBlock) {
        view.cancelBlock = cancelBlock;
    }
    return view;
}

- (IBAction)ok:(id)sender {
    NSString *date = [NSDate _wj_stringWithDate:self.datePick.date format:@"yyyy-MM-dd"];
    DLog(@"%@",date);
    if (self.successBlock) {
        self.successBlock(date);
    }
}

- (IBAction)cancel:(id)sender {
    if (self.cancelBlock) {
        self.cancelBlock(@"");
    }
}
- (IBAction)datePickChange:(id)sender {
}

@end
